from django.urls import path, include
from django.conf.urls import url
from django.contrib.auth.models import User
from rest_framework import routers, viewsets
from app_service.views import (
    http_view,
    class_view,
    user_view,
    auth_view,
    student_view,
    school_view,
)

urlpatterns = [
    path('api/get', http_view.get_api_view),
    path('api/post', http_view.post_api_view),
    path('api/form', http_view.form_api_view),
    path('school/api/<int:pk>', school_view.school_api),

    url(r'^schools$', school_view.SchoolsAPI.as_view()),
    url(r'^school/(?P<pk>[0-9]+)$', school_view.SchoolAPI.as_view()),

    url(r'^student/v1/$', student_view.StudentAPIView.as_view()),
    url(r'^user/login/$', user_view.LoginView.as_view()),
    url(r'^user/logout/$', user_view.LogoutView.as_view()),

    url(r'^auth/api/view$', auth_view.AuthAPIView.as_view()),
    url(r'^class/api/view$', class_view.ClassAPIView.as_view()),

]

# 路由
router = routers.DefaultRouter()
router.register(r'student/v2', student_view.StudentGenericViewSet)
router.register(r'student/v3', student_view.StudentModelViewSet)
router.register(r'school-api', school_view.SchoolViewSet)
router.register(r'person-api', student_view.StudentGenericViewSet)

router.register(r'auth/view/set', auth_view.AuthViewSet, basename='auth/view/set')
router.register(r'class/view/set', class_view.ClassViewSet, basename='class/view/set')

urlpatterns += router.urls
